'use strict';

/* Controllers */

var appControllers = angular.module('myApp.controllers', []);

appControllers.controller('AppCtrl', function ($scope, $http) {

    $http({
        method: 'GET',
        url: '/api/name'
    }).
        success(function (data, status, headers, config) {
            $scope.name = data.name;
        }).
        error(function (data, status, headers, config) {
            $scope.name = 'Error!'
        });

});

appControllers.controller('PartialController', function ($scope) {

});

appControllers.controller('NavController', ['$scope', '$location', function ($scope, $location) {

    $scope.className = function (href) {
        var currentRoute = $location.path() || '/';
        console.log('class name', href, currentRoute);
        return href === currentRoute ? 'active' : '';
    };

    $scope.navItems = [
        {'name': 'Home', 'href': '/home'},
        {'name': 'Projects', 'href': '/projects'},
        {'name': 'Services', 'href': '/services'},
        {'name': 'Downloads', 'href': '/downloads'},
        {'name': 'About', 'href': '/about'},
        {'name': 'Contact', 'href': '/contact'}
    ];

}]);